package com.swzl.common.configure;

import com.swzl.common.configure.interceptor.RequestInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * 注册拦截器
 *
 * @author fog
 * @date 2024年11月03日 17:09
 */

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    private RequestInterceptor requestInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截器
        registry.addInterceptor(requestInterceptor)
                // 拦截所有请求
                .addPathPatterns("/**")
                // 登陆请求不需要
                .excludePathPatterns("/api/login");
    }
}
